#:import _ electrum.gui.kivy.i18n._
#:import KIVY_GUI_PATH electrum.gui.kivy.KIVY_GUI_PATH
#:import pr_color electrum.invoices.pr_color
#:import PR_UNKNOWN electrum.invoices.PR_UNKNOWN
#:import Factory kivy.factory.Factory
#:import Decimal decimal.Decimal
#:set btc_symbol chr(171)
#:set mbtc_symbol chr(187)
#:set font_light f'{KIVY_GUI_PATH}/data/fonts/Roboto-Condensed.ttf'

<PaymentLabel@Label>
    #color: .305, .309, .309, 1
    text_size: self.width, None
    halign: 'left'
    valign: 'top'

<PaymentItem@CardItem>
    key: ''
    address: ''
    memo: ''
    amount: ''
    status: PR_UNKNOWN
    status_str: ''
    date: ''
    BoxLayout:
        spacing: '8dp'
        height: '32dp'
        orientation: 'vertical'
        Widget
        PaymentLabel:
            text: root.memo
            shorten: True
            shorten_from: 'right'
        Widget
        PaymentLabel:
            text: root.address
            color: .699, .699, .699, 1
            font_size: '13sp'
            shorten: True
        Widget
    BoxLayout:
        spacing: '8dp'
        height: '32dp'
        orientation: 'vertical'
        Widget
        PaymentLabel:
            text: root.amount
            halign: 'right'
            font_size: '15sp'
        Widget
        PaymentLabel:
            text: root.status_str
            halign: 'right'
            font_size: '13sp'
            color: pr_color[root.status]
        Widget

<PaymentRecycleView>:
    viewclass: 'PaymentItem'
    RecycleBoxLayout:
        default_size: None, dp(56)
        default_size_hint: 1, None
        size_hint: 1, None
        height: self.minimum_height
        orientation: 'vertical'

<SendScreen>:
    id: s
    name: 'send'
    address: ''
    amount: ''
    message: ''
    is_bip70: False
    is_lightning: False
    is_locked: self.is_lightning or self.is_bip70
    BoxLayout
        padding: '12dp', '12dp', '12dp', '12dp'
        spacing: '12dp'
        orientation: 'vertical'
        SendReceiveBlueBottom:
            id: blue_bottom
            size_hint: 1, None
            height: self.minimum_height
            BoxLayout:
                size_hint: 1, None
                height: blue_bottom.item_height
                spacing: '5dp'
                Image:
                    source: f'atlas://{KIVY_GUI_PATH}/theming/light/lightning' if root.is_lightning else f'atlas://{KIVY_GUI_PATH}/theming/light/globe'
                    size_hint: None, None
                    size: '22dp', '22dp'
                    pos_hint: {'center_y': .5}
                BlueButton:
                    id: payto_e
                    text: s.address if s.address else _('Recipient')
                    shorten: True
                    on_release: Clock.schedule_once(lambda dt: app.show_info(_('Copy and paste the recipient address using the Paste button, or use the camera to scan a QR code.')))
                    #on_release: Clock.schedule_once(lambda dt: app.popup_dialog('contacts'))
            CardSeparator:
                color: blue_bottom.foreground_color
            BoxLayout:
                size_hint: 1, None
                height: blue_bottom.item_height
                spacing: '5dp'
                Image:
                    source: f'atlas://{KIVY_GUI_PATH}/theming/light/calculator'
                    opacity: 0.7
                    size_hint: None, None
                    size: '22dp', '22dp'
                    pos_hint: {'center_y': .5}
                BlueButton:
                    id: amount_e
                    default_text: _('Amount')
                    text: s.amount if s.amount else _('Amount')
                    disabled: root.is_bip70 or (root.is_lightning and s.amount)
                    on_release: Clock.schedule_once(lambda dt: app.amount_dialog(s, not root.is_lightning))
            CardSeparator:
                color: blue_bottom.foreground_color
            BoxLayout:
                id: message_selection
                size_hint: 1, None
                height: blue_bottom.item_height
                spacing: '5dp'
                Image:
                    source: f'atlas://{KIVY_GUI_PATH}/theming/light/pen'
                    size_hint: None, None
                    size: '22dp', '22dp'
                    pos_hint: {'center_y': .5}
                BlueButton:
                    id: description
                    text: s.message if s.message else (_('No Description') if root.is_locked else _('Description'))
                    disabled: root.is_locked
                    on_release: Clock.schedule_once(lambda dt: app.description_dialog(s))
        BoxLayout:
            size_hint: 1, None
            height: '48dp'
            IconButton:
                size_hint: 0.5, 1
                on_release: s.do_save()
                icon: f'atlas://{KIVY_GUI_PATH}/theming/light/save'
            IconButton:
                size_hint: 0.5, 1
                on_release: s.do_clear()
                icon: f'atlas://{KIVY_GUI_PATH}/theming/light/closebutton'
            IconButton:
                size_hint: 0.5, 1
                icon: f'atlas://{KIVY_GUI_PATH}/theming/light/copy'
                on_release: s.do_paste()
            Button:
                id: qr
                text:_('Scan')
                size_hint: 1, 1
                on_release: Clock.schedule_once(lambda dt: app.scan_qr(on_complete=app.on_qr))
            Button:
                text: _('Pay')
                size_hint: 1, 1
                on_release: s.do_pay()
        Widget:
            size_hint: 1, 0.1
        PaymentRecycleView:
            id: payments_container
            scroll_type: ['bars', 'content']
            bar_width: '25dp'
